import pymysql

class DB():
    def __init__(self):
        self.conn = pymysql.connect(host='localhost',port=3306,user='root',password='mysql',db='p9',charset='utf8',cursorclass=pymysql.cursors.DictCursor)
        self.aaa = self.conn.cursor()

    def update(self,sql):
        self.aaa.execute(sql)
        self.conn.commit()

    def find(self,sql):
        self.aaa.execute(sql)
        res = self.aaa.fetchone()
        return res

    def findall(self,sql):
        self.aaa.execute(sql)
        res = self.aaa.fetchall()
        return res

    def close(self):
        self.aaa.close()
        self.conn.close()

db1 = DB()

